package com.xyy.saas.payment.util.xydSign;

public class Byte2HexUtil {
    private static final String hexDigits[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};

    /**
     * 转换字节数组为十六进制字符串
     *
     * @param b
     * @return
     */
    public static String byteArrayToHexString(byte b[]) {
        StringBuffer resultSb = new StringBuffer();
        for (int i = 0; i < b.length; i++)
            resultSb.append(byteToHexString(b[i]));

        return resultSb.toString();
    }

    private static String byteToHexString(byte b) {
        return hexDigits[(b >> 4) & 0x0f] + hexDigits[b & 0x0f];
    }

}
